﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Komunikator.Core;

namespace Komunikator
{
    /// <summary>
    /// Interaction logic for DescriptionWindow.xaml
    /// </summary>
    public partial class DescriptionWindow : Window
    {

        MainWindow mwHandle;

        public DescriptionWindow(MainWindow mw)
        {
            mwHandle = mw;
            InitializeComponent();
            textBox1.MaxLength = 160;
            CounterLabel.Content = 255;
        }

        private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
            byte[] utf8Desc = UTF8Encoding.UTF8.GetBytes(textBox1.Text);
            CounterLabel.Content = (255 - utf8Desc.Length).ToString();

            if ((255 - utf8Desc.Length) < 0)
            {
                textBox1.Undo();
            }
        }

        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            if (textBox1.Text != String.Empty)
            {
                DescriptionController.descriptionStatus = true;
                DescriptionController.descriptionString = textBox1.Text;
            }
        }


    }
}
